#include "Timer.h"
#include <SDL.h>
#include <iostream>


Timer::Timer()
{
	m_dt = 0.0;
	m_oldTicks = 0;
}

void Timer::Update()
{
	unsigned int newTicks = SDL_GetTicks();
	unsigned int diff = newTicks - m_oldTicks;
	m_oldTicks = newTicks;
	m_dt = (float)diff / 1000.0f;

	const float MAX_DT = 1.0f;
	if (m_dt > MAX_DT)
	{
		m_dt = MAX_DT;
	}

	std::cout << m_dt << "\n";
}

float Timer::GetDt() const
{
	return m_dt;
}

unsigned int Timer::GetElapsedTime()
{
	return m_oldTicks;
}